﻿@model IEnumerable<OnlineStore.Models.ProductInCart>

@{
    ViewBag.Title = "index";
    Layout = "_Layout1";
    double sum = 0;
    int i = 0;//计数
}



<div class="CarMainPart table-responsive">
    <table class="table">
        <thead>
            <tr>
                <td>序号</td>
                <td>商品详情</td>
                <td>商品单价</td>
                <td>商品数量</td>
                <td>总金额</td>
                <td>删除</td>

            </tr>
        </thead>

        <tbody>
            @foreach (var product in Model)
            {
              
                double price;
                var count = product.Quantity;

                <tr>
                    <td style="padding-top:25px;">@i</td>
                    <td>
                        <div class="">
                            <p><img src="@product.Product.ImageUrl" width="120" height="150" /></p>
                            <p style="margin-top:15px;">书名:<span>@product.Product.Name</span></p>
                            <p>作者：@product.Product.Author</p>
                        </div>
                    </td>
                    <td style="padding-top:25px;">@product.Product.Price </td>


                    <td class="total_price " style="padding-top:25px;">
                        <form asp-action="Edit" asp-controller="Cart" method="post">
                            <div class="input-group">
                            @if(count>1){ 
                                  <span class="input-group-btn">
                                      <button class="btn btn-default" id="plus" type="submit" asp-controller="Cart" asp-action="Edit" asp-route-productId="@product.Product.Id" asp-route-quantity="@(count - 1)">-</button>
                                  </span>
                            }
                                <input type="text" id="text" class="form-control" placeholder=@product.Quantity value="@product.Quantity ">
                                <span class="input-group-btn">
                                    <button class="btn btn-default" type="submit" id="subtract"  asp-controller="Cart" asp-action="Edit" asp-route-productId="@product.Product.Id" asp-route-quantity="@(count + 1)" >+</button>
                                </span>
                            </div>
                        </form>
                    </td>



                    @{price = double.Parse((@product.Quantity * @product.Product.Price).ToString());}

                    <td style="padding-top:25px;">@price</td>
                    <form asp-action="Delete" asp-controller="Cart" method="post">
                        <td style="padding-top:25px;">
                            <button type="submit" class="btn btn-danger" asp-controller="Cart" asp-action="Delete" asp-route-productId="@product.Product.Id" >删除</button>
                        </td>
                    </form>
                </tr>
                sum = sum + price;
                i++;
            }
        </tbody>
    </table>
</div>
<div class="row clearfix settle">
    <div class="col-md-2 offset-md-10 column text-center">
        <span class="accounts">结账：</span>
        <form method="get">
            <button type="submit" class="btn btn-danger btn-lg btn-accounts" asp-action="AddOrder" asp-controller="Orders">￥<span>@sum</span></button>
        </form>
    </div>
</div>



@*<div class="row clearfix">
        <div class="col-md-12 column">
            <div id="modal-container-418866" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
                 class="modal fade" style="display:none">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" data-dismiss="modal" aria-hidden="true" class="close">×</button>
                            <h4 id="myModalLabel" class="modal-title">您要删除商品吗？</h4>
                        </div>
                        <div class="modal-body text-center">
                            您要删除商品吗?
                        </div>
                        <div class="modal-footer">
                            <button type="button" data-dismiss="modal" class="btn btn-default">关闭</button>
                            <button type="button" data-dismiss="modal" class="btn btn-danger">删除</button>

                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>*@

